const app = getApp();
Component({
  /**
   * 组件的一些选项
   */
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的对外属性
   */
  properties: {
    bgColor: {
      type: String,
      default: ''
    }, 
    isCustom: {
      type: Boolean,
      default: false
    },
    isBack: {
      type: Boolean,
      default: false
    },
    bgImage: {
      type: String,
      default: ''
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    Custom: app.globalData.Custom,
    needAlert: false
  },
  /**
   * 组件的方法列表
   */
  methods: {
    BackPage() {
      wx.disableAlertBeforeUnload({
          success: function (res) {
          },
          fail: function (errMsg) {
          },
      });
      if(this.data.needAlert){
        // 需要确认
        let self = this;
        wx.showModal({
          title: '提醒',
          content: '确定要放弃当前填写内容嘛？',
          success(res) {
            if (res.confirm) {
              var that = self;
              wx.navigateBack({
                delta: 1,
                fail: function(){
                  that.toHome();
                }
              });
            } 
          }
        })
      }else{
        var that = this;
        wx.navigateBack({
          delta: 1,
          fail: function(){
            that.toHome();
          }
        });
      }
    },
    toHome(){
      wx.reLaunch({
        url: '/pages/home/home',
      })
    }
  }
})